<template>
  <div>
    <script :id=id type="text/plain"></script>
  </div>
</template>
<script>
import 'public/UE/ueditor.config.js'
import 'public/UE/ueditor.all.min.js'
import 'public/UE/lang/zh-cn/zh-cn.js'
import 'public/UE/ueditor.parse.min.js'
import 'public/xiumi/xiumi-ue-dialog-v5.js'
import 'public/xiumi/xiumi-ue-v5.css'
  export default {
    name: 'UE',
    data () {
      return {
        editor: null,
        config: {

        }
      }
    },
    props: {
      defaultMsg: {
        type: String
      },
      id: {
        type: String
      },
    },
    mounted() {
      const _this = this;
      this.editor = UE.getEditor(this.id); // 初始化UE
      this.editor.addListener("ready", function () {
        _this.editor.setContent(_this.defaultMsg); // 确保UE加载完成后，放入内容。
      });
      // console.log("上传这堆错误不用理会，上传接口需自行开发配置");
    },
    methods: {
      getUEContent() { // 获取内容方法
        return this.editor.getContent()
      },
      getUEContentTxt() { // 获取纯文本内容方法
        return this.editor.getContentTxt()
      },
      setUEContent(content) {
        return this.editor.setContent(content)
      }
    },
    destroyed() {
      this.editor.destroy();
    },
    // watch: {
    //   defaultMsg(newVal, oldVal) {
    //     if(newVal != oldVal){
    //       this.editor.setContent(newVal)
    //     }
    //   }
    // }
  }
</script>
<style lang="scss">
    .edui-editor{
        .edui-box{
            .edui-default{
                line-height: 1px;
            }
        }
    }
</style>
